home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Windows marzen / Maxthon 2.0.4 / mx_2.0.4.5799.exe / template / _shared / js / maxTable.js < prev    next >
Text File  |  2007-09-20  |  18KB  |  670 lines

  1. var maxTable={};
  2. maxTable.create=function(id){
  3. return {"objID":id,"id":id,"wrapperID":id+"_wrapper","tableTag":" width=\"96%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"","style":{"table":"maxTable","control":"maxTable-control","edit-control":"maxTable-edit-control","edit-note":"maxTable-edit-note","row":"maxTable-row","hover":"maxTable-hover","edit":"maxTable-edit","separator":"maxTable-separator","separator-hover":"maxTable-separator-hover","separator-edit":"maxTable-separator-edit"},"dataType":"array","columns":[],"data":[],"defaultRowData":[],"separatorType":"none","defaultSeparatorText":"---","lang":{"delete_confirm":"Are you sure to delete this item?","required":"\"%s\" can not be blank.","not_saved":"You have not saved your changes. Click \"OK\" to save now."},"allowInsert":true,"allowEdit":true,"allowEditSeparator":true,"showEditControl":true,"editControl":[{type:"move_up"},{type:"html",value:" "},{type:"move_down"},{type:"html",value:" | "},{type:"delete",hideOnNew:true},{type:"html",value:" | ",hideOnNew:true},{type:"save"},{type:"html",value:" | "},{type:"cancel"}],"controlUI":{"add":"Add Item","add_sep":"Add Separator","separator":" ","move_up":"<img src=\"images/btn_up.png\" />","move_down":"<img src=\"images/btn_down.png\" />","delete":"Delete","save":"Save","cancel":"Cancel","radio":"<img src=\"images/btn_radio.png\" />","radio_checked":"<img src=\"images/btn_radio_checked.png\" />","checkbox":"<img src=\"images/btn_check.png\" />","checkbox_checked":"<img src=\"images/btn_check_checked.png\" />"},"content":{"buildTableControls":null,"buildEditControls":null},"event":{"beforeInit":function(){
  4. return true;
  5. },"afterInit":function(){
  6. },"beforeDestroy":function(){
  7. return true;
  8. },"afterDestroy":function(){
  9. },"beforeEdit":function(){
  10. return true;
  11. },"afterEdit":function(){
  12. },"beforeCancel":function(){
  13. return true;
  14. },"afterCancel":function(){
  15. },"beforeAdd":function(){
  16. return true;
  17. },"afterAdd":function(){
  18. },"beforeUpdate":function(){
  19. return true;
  20. },"afterUpdate":function(){
  21. },"beforeDelete":function(_2){
  22. return true;
  23. },"afterDelete":function(_3){
  24. },"beforeRadioClick":function(_4,_5){
  25. return true;
  26. },"afterRadioClick":function(_6,_7,_8){
  27. },"beforeCheckboxClick":function(_9,_a){
  28. return true;
  29. },"afterCheckboxClick":function(_b,_c){
  30. }},"inAction":"","inEditRow":null,"inEditDataIndex":-1,"inEditBackupData":null,"inEditResultData":null,"moveOffset":0};
  31. };
  32. maxTable.init=function(_d){
  33. _d.inAction="init";
  34. if(!_d.event.beforeInit()){
  35. return false;
  36. }
  37. maxTable.ui.attachTable(_d);
  38. _d.event.afterInit();
  39. _d.inAction="";
  40. };
  41. maxTable.destroy=function(_e){
  42. _e.inAction="destroy";
  43. if(!_e.event.beforeDestroy()){
  44. return false;
  45. }
  46. maxTable.ui.detachTable(_e);
  47. _e.event.afterDestroy();
  48. delete _e;
  49. };
  50. maxTable.ui={};
  51. maxTable.ui.attachTable=function(_f){
  52. if(!(_f.data instanceof Array)){
  53. alert("maxTable.ui.attachTable : "+_f.id+".data is not an Array\n"+$toJSON(_f.data));
  54. return;
  55. }
  56. var obj=$id(_f.wrapperID);
  57. if(obj){
  58. obj.innerHTML=maxTable.ui.buildTable(_f);
  59. }else{
  60. alert("maxTable.ui.attachTable : "+_f.wrapperID+" not Found");
  61. }
  62. };
  63. maxTable.ui.detachTable=function(_11){
  64. var obj=$id(_11.wrapperID);
  65. if(obj){
  66. obj.innerHTML="";
  67. }
  68. };
  69. maxTable.ui.buildTable=function(_13){
  70. var _14="<table id=\""+_13.id+"\" "+_13.tableTag+" class=\""+_13.style["table"]+"\">\n";
  71. _14+=maxTable.ui.buildHeader(_13);
  72. for(var i=0;i<_13.data.length;i++){
  73. _14+=maxTable.ui.buildRow(_13,i);
  74. }
  75. _14+=maxTable.ui.buildFooter(_13);
  76. _14+="</table>\n";
  77. return _14;
  78. };
  79. maxTable.ui.buildHeader=function(_16){
  80. var _17="<tr>\n";
  81. for(var i=0;i<_16.columns.length;i++){
  82. var _19="";
  83. if(_16.columns[i].width){
  84. _19+=" width=\""+_16.columns[i].width+"\"";
  85. }
  86. if(_16.columns[i].tagx){
  87. _19+=_16.columns[i].tagx;
  88. }
  89. _17+="<th"+_19+">"+_16.columns[i].title+"</th>";
  90. }
  91. _17+="</tr>\n";
  92. return _17;
  93. };
  94. maxTable.ui.buildFooter=function(_1a){
  95. var _1b="";
  96. if(_1a.allowInsert){
  97. _1b+="<tr class=\""+_1a.style["control"]+"\">"+"<td colspan=\""+_1a.columns.length+"\">";
  98. if(_1a.content["buildTableControls"]){
  99. _1b+=_1a.content.buildTableControls();
  100. }else{
  101. _1b+="<a href=\"javascript:;\" onclick=\"maxTable.action.addRow("+_1a.objID+")\">"+_1a.controlUI["add"]+"</a>";
  102. if(_1a.separatorType!="none"&&_1a.allowEditSeparator){
  103. _1b+="  |  "+"<a href=\"javascript:;\" onclick=\"maxTable.action.addRow("+_1a.objID+", true)\">"+_1a.controlUI["add_sep"]+"</a>";
  104. }
  105. }
  106. _1b+="</td>"+"</tr>\n";
  107. }
  108. return _1b;
  109. };
  110. maxTable.ui.buildRow=function(_1c,_1d){
  111. var _1e="";
  112. var _1f=maxTable.ui.buildCellHTML(_1c,_1d);
  113. if(_1f.type=="array"){
  114. _1e+="<tr onclick=\"maxTable.action.editRow("+_1c.objID+", this)\""+" onmouseover=\"this.className='"+_1c.style["hover"]+"'\" onmouseout=\"this.className='"+_1c.style["row"]+"'\""+" class=\""+_1c.style["row"]+"\">\n";
  115. for(var i=0;i<_1f.data.length;i++){
  116. _1e+="<td"+(_1c.columns[i].width?" width=\""+_1c.columns[i].width+"\"":"")+(_1c.columns[i].tagx?_1c.columns[i].tagx:"")+(_1f.data[i].onclick?" onclick=\""+_1f.data[i].onclick+"\"":"")+">"+_1f.data[i].html+"</td>\n";
  117. }
  118. _1e+="</tr>\n";
  119. }else{
  120. _1e+="<tr"+(_1c.allowEditSeparator?" onclick=\"maxTable.action.editRow("+_1c.objID+", this)\""+" onmouseover=\"this.className='"+_1c.style["separator-hover"]+"'\" onmouseout=\"this.className='"+_1c.style["separator"]+"'\"":"")+" class=\""+_1c.style["separator"]+"\">\n"+"<td colspan=\""+_1c.columns.length+"\">"+_1f.data+"</td>"+"</tr>\n";
  121. }
  122. return _1e;
  123. };
  124. maxTable.ui.addRow=function(_21,_22,_23){
  125. var _24=$id(_21.id);
  126. var _25=_24.rows.length-(_21.allowInsert?1:0);
  127. var _26=_24.insertRow(_25);
  128. var _27;
  129. if(_21.separatorType!="none"&&_22){
  130. _27=_26.insertCell();
  131. _27.colSpan=_21.columns.length;
  132. if(_23){
  133. _21.data.push(_23);
  134. }else{
  135. _21.data.push(_21.defaultSeparatorText);
  136. }
  137. }else{
  138. for(var i=0;i<_21.columns.length;i++){
  139. _27=_26.insertCell();
  140. maxTable.action.addRowEventHelper(_21,_27,i);
  141. }
  142. if(_23){
  143. _21.data.push(_23);
  144. }else{
  145. _21.data.push($clone(_21.defaultRowData));
  146. }
  147. }
  148. maxTable.ui.updateRow(_21,_21.data.length-1);
  149. return _21.data.length-1;
  150. };
  151. maxTable.ui.deleteRow=function(_29,_2a){
  152. var _2b=$id(_29.id);
  153. if(_29.showEditControl&&_29.inEditDataIndex==_2a&&_29.inAction=="edit"){
  154. _2b.deleteRow(_2a+2);
  155. _29.inAction="";
  156. _29.inEditRow=null;
  157. _29.inEditDataIndex=-1;
  158. }
  159. _2b.deleteRow(_2a+1);
  160. var _2c=_29.data.splice(_2a,1)[0];
  161. return _2c;
  162. };
  163. maxTable.ui.editRow=function(_2d,_2e){
  164. if(_2d.inAction=="pre_add"){
  165. _2d.inAction="add";
  166. }else{
  167. _2d.inAction="edit";
  168. }
  169. _2d.inEditRow=$id(_2d.id).rows(_2e+1);
  170. _2d.inEditDataIndex=_2e;
  171. _2d.moveOffset=0;
  172. _2d.inEditBackupData=$clone(_2d.data[_2d.inEditDataIndex]);
  173. maxTable.ui.updateRow(_2d,_2d.inEditDataIndex);
  174. if(_2d.showEditControl){
  175. var _2f=$id(_2d.id).insertRow(_2d.inEditRow.rowIndex+1);
  176. _2f.className=_2d.style["edit-control"];
  177. var _30=_2f.insertCell();
  178. _30.colSpan=_2d.columns.length;
  179. _30.innerHTML=maxTable.ui.buildEditControls(_2d);
  180. }
  181. _30=null;
  182. _2f=null;
  183. };
  184. maxTable.ui.cancelEditRow=function(_31){
  185. if(_31.showEditControl){
  186. $id(_31.id).deleteRow(_31.inEditRow.rowIndex+1);
  187. }
  188. if(_31.moveOffset!=0){
  189. var _32=$id(_31.id);
  190. _32.moveRow(_31.inEditRow.rowIndex,_31.inEditRow.rowIndex-_31.moveOffset);
  191. }
  192. if(_31.inAction=="add"){
  193. _31.data.splice(_31.inEditRow.rowIndex-1,1);
  194. _31.inEditRow.removeNode(true);
  195. }else{
  196. if(_31.inAction!="save"){
  197. _31.data[_31.inEditDataIndex]=$clone(_31.inEditBackupData);
  198. }
  199. _31.inAction="";
  200. maxTable.ui.updateRow(_31,_31.inEditDataIndex);
  201. }
  202. _31.inAction="";
  203. _31.inEditRow=null;
  204. _31.inEditDataIndex=-1;
  205. };
  206. maxTable.ui.doCheckbox=function(_33,_34,_35,_36){
  207. var col=_35;
  208. if(_33.columns[_35].name){
  209. col=_33.columns[_35].name;
  210. }
  211. if(_36!=undefined){
  212. _33.data[_34][col]=_36;
  213. }else{
  214. var _38=_33.data[_34][col];
  215. if(_38){
  216. _33.data[_34][col]=false;
  217. }else{
  218. _33.data[_34][col]=true;
  219. }
  220. }
  221. maxTable.ui.updateRow(_33,_34);
  222. };
  223. maxTable.ui.updateRow=function(_39,_3a){
  224. var _3b=false;
  225. var _3c=1;
  226. if(_39.inAction=="edit"||_39.inAction=="add"){
  227. _3b=true;
  228. if(_39.inEditDataIndex!=_3a){
  229. _3b=false;
  230. }
  231. _3c=_39.inEditDataIndex<_3a?2:1;
  232. }
  233. var _3d=$id(_39.id).rows(_3a+_3c);
  234. if(!_3d){
  235. return;
  236. }
  237. var _3e=maxTable.ui.buildCellHTML(_39,_3a);
  238. if(!_3e){
  239. return;
  240. }
  241. if(_3e.type=="array"){
  242. if(_3b){
  243. _3d.onclick=null;
  244. _3d.onmouseover=null;
  245. _3d.onmouseout=null;
  246. _3d.className=_39.style["edit"];
  247. }else{
  248. _3d.onclick=function(){
  249. return maxTable.action.editRow(_39,this);
  250. };
  251. _3d.onmouseover=function(){
  252. this.className=_39.style["hover"];
  253. };
  254. _3d.onmouseout=function(){
  255. this.className=_39.style["row"];
  256. };
  257. _3d.className=_39.style["row"];
  258. }
  259. for(var i=0;i<_3e.data.length;i++){
  260. if(!_3e.data[i].noUpdate){
  261. _3d.cells[i].innerHTML=_3e.data[i].html;
  262. }
  263. }
  264. }else{
  265. _3d.cells[0].colSpan=_39.columns.length;
  266. _3d.cells[0].innerHTML=_3e.data;
  267. if(_3b){
  268. _3d.onclick=null;
  269. _3d.onmouseover=null;
  270. _3d.onmouseout=null;
  271. _3d.className=_39.style["separator-edit"];
  272. }else{
  273. _3d.onclick=function(){
  274. return maxTable.action.editRow(_39,this);
  275. };
  276. _3d.onmouseover=function(){
  277. this.className=_39.style["separator-hover"];
  278. };
  279. _3d.onmouseout=function(){
  280. this.className=_39.style["separator"];
  281. };
  282. _3d.className=_39.style["separator"];
  283. }
  284. }
  285. };
  286. maxTable.ui.buildCellHTML=function(_40,_41){
  287. var _42=_40.data[_41];
  288. if(!_42){
  289. return null;
  290. }
  291. if(maxTable.data.isSeparator(_40,_41)){
  292. var _43="";
  293. if(_40.separatorType=="text"){
  294. if(_40.inAction=="edit"||_40.inAction=="add"){
  295. _43="<input id=\""+_40.id+"_edit_0\""+" value=\""+_42.$encodeHTML()+"\" type=\"text\" class=\"text\" />";
  296. }else{
  297. _43=_42.$encodeHTML();
  298. }
  299. }else{
  300. _43=_40.controlUI["separator"];
  301. }
  302. return {type:"separator",data:_43};
  303. }else{
  304. var _44=[];
  305. for(var i=0;i<_40.columns.length;i++){
  306. var _46=i;
  307. if(_40.dataType=="object"){
  308. _46=_40.columns[i].name;
  309. _44[i]={};
  310. }else{
  311. _44[i]=[];
  312. }
  313. switch(_40.columns[i].type){
  314. case "radio":
  315. if(_40.columns[i].customUI){
  316. _44[i]["html"]=(_42[_46]==true?_40.columns[i].customUI["checked"]:_40.columns[i].customUI["unchecked"]);
  317. }else{
  318. _44[i]["html"]=(_42[_46]==true?_40.controlUI["radio_checked"]:_40.controlUI["radio"]);
  319. }
  320. if(!_40.columns[i].readOnly){
  321. if(_40.inAction=="init"){
  322. _44[i]["onclick"]="maxTable.action.radioClick("+_40.objID+", this, "+i+")";
  323. }
  324. }
  325. break;
  326. case "checkbox":
  327. if(_40.columns[i].customUI){
  328. _44[i]["html"]=(_42[_46]==true?_40.columns[i].customUI["checked"]:_40.columns[i].customUI["unchecked"]);
  329. }else{
  330. _44[i]["html"]=(_42[_46]==true?_40.controlUI["checkbox_checked"]:_40.controlUI["checkbox"]);
  331. }
  332. if(!_40.columns[i].readOnly){
  333. if(_40.inAction=="init"){
  334. _44[i]["onclick"]="maxTable.action.checkBoxClick("+_40.objID+", this, "+i+")";
  335. }
  336. }
  337. break;
  338. case "select":
  339. if(!_40.columns[i].readOnly&&(_40.inAction=="edit"||_40.inAction=="add")){
  340. _44[i]["html"]="<select id=\""+_40.id+"_edit_"+_46+"\""+">";
  341. for(var j=0;j<_40.columns[i].selectOptions.length;j++){
  342. _44[i]["html"]+="<option value=\""+_40.columns[i].selectOptions[j][1]+"\""+(_42[_46]==_40.columns[i].selectOptions[j][1]?" selected=\"selected\"":"")+">"+_40.columns[i].selectOptions[j][0]+"</option>";
  343. }
  344. _44[i]["html"]+="</select>";
  345. }else{
  346. if(_42[_46]==""){
  347. _44[i]["html"]=" ";
  348. }else{
  349. _44[i]["html"]=_42[_46].$encodeHTML();
  350. }
  351. }
  352. break;
  353. case "textarea":
  354. if(!_40.columns[i].readOnly&&(_40.inAction=="edit"||_40.inAction=="add")){
  355. _44[i]["html"]="<textarea id=\""+_40.id+"_edit_"+_46+"\""+(_40.columns[i].rows?" rows=\""+_40.columns[i].rows+"\"":"")+">"+_42[_46].$encodeHTML(true)+"</textarea>";
  356. }else{
  357. if(_42[_46]==""){
  358. _44[i]["html"]=" ";
  359. }else{
  360. _44[i]["html"]=_42[_46].$encodeHTML();
  361. }
  362. }
  363. break;
  364. case "html":
  365. if(_40.inAction=="init"){
  366. _44[i]["html"]=_42[_46];
  367. }else{
  368. _44[i]["noUpdate"]=true;
  369. }
  370. break;
  371. case "custom":
  372. var tmp=_40.columns[i].customBuilder(_41,i);
  373. if(tmp==null){
  374. _44[i]["noUpdate"]=true;
  375. }else{
  376. _44[i]["html"]=_40.columns[i].customBuilder(_41,i);
  377. }
  378. break;
  379. default:
  380. if(!_40.columns[i].readOnly&&(_40.inAction=="edit"||_40.inAction=="add")){
  381. _44[i]["html"]="<input id=\""+_40.id+"_edit_"+_46+"\""+" value=\""+_42[_46].$encodeHTML()+"\" type=\"text\" class=\"text\" />";
  382. }else{
  383. if(_42[_46]==""){
  384. _44[i]["html"]=" ";
  385. }else{
  386. _44[i]["html"]=_42[_46].$encodeHTML();
  387. }
  388. }
  389. }
  390. if(_40.columns[i].editNote&&(_40.inAction=="edit"||_40.inAction=="add")){
  391. _44[i]["html"]+="<div class=\""+_40.style["edit-note"]+"\">"+_40.columns[i].editNote+"</div>";
  392. }
  393. }
  394. return {type:"array",data:_44};
  395. }
  396. };
  397. maxTable.ui.buildEditControls=function(_49){
  398. if(_49.content["buildEditControls"]){
  399. return _49.content.buildEditControls();
  400. }
  401. var str="";
  402. for(var i=0;i<_49.editControl.length;i++){
  403. if(_49.editControl[i].hideOnNew&&_49.inAction=="add"){
  404. continue;
  405. }
  406. switch(_49.editControl[i].type){
  407. case "move_up":
  408. str+="<a href=\"javascript:;\" onclick=\"maxTable.action.moveRow("+_49.objID+", -1)\">"+_49.controlUI["move_up"]+"</a>";
  409. break;
  410. case "move_down":
  411. str+="<a href=\"javascript:;\" onclick=\"maxTable.action.moveRow("+_49.objID+", 1)\">"+_49.controlUI["move_down"]+"</a>";
  412. break;
  413. case "delete":
  414. str+="<a href=\"javascript:;\" onclick=\"maxTable.action.deleteEdit("+_49.objID+")\">"+_49.controlUI["delete"]+"</a>";
  415. break;
  416. case "save":
  417. str+="<a href=\"javascript:;\" onclick=\"maxTable.action.saveEdit("+_49.objID+")\">"+_49.controlUI["save"]+"</a>";
  418. break;
  419. case "cancel":
  420. str+="<a href=\"javascript:;\" onclick=\"maxTable.action.cancelEdit("+_49.objID+")\">"+_49.controlUI["cancel"]+"</a>";
  421. break;
  422. case "html":
  423. str+=_49.editControl[i].value;
  424. break;
  425. }
  426. }
  427. return str;
  428. };
  429. maxTable.data={};
  430. maxTable.data.isSeparator=function(_4c,_4d){
  431. return (_4c.separatorType!="none"&&typeof (_4c.data[_4d])=="string");
  432. };
  433. maxTable.data.getEditResult=function(_4e){
  434. var _4f=$clone(_4e.data[_4e.inEditDataIndex]);
  435. if(maxTable.data.isSeparator(_4e,_4e.inEditDataIndex)){
  436. if(_4e.separatorType=="text"){
  437. _4f=$id(_4e.id+"_edit_0").value;
  438. if(_4f.replace(" ","")==""){
  439. alert(_4e.lang["sep_require"]);
  440. return null;
  441. }
  442. }else{
  443. _4f="---";
  444. }
  445. }else{
  446. for(var i=0;i<_4e.columns.length;i++){
  447. if(!_4e.columns[i].readOnly){
  448. var _51=i;
  449. if(_4e.dataType=="object"){
  450. _51=_4e.columns[i].name;
  451. }
  452. if(_4e.columns[i].type=="text"||_4e.columns[i].type=="textarea"){
  453. _4f[_51]=$id(_4e.id+"_edit_"+_51).value;
  454. }
  455. if(_4e.columns[i].type=="select"){
  456. var obj=$id(_4e.id+"_edit_"+_51);
  457. _4f[_51]=obj.options[obj.selectedIndex].value;
  458. }
  459. if(_4e.columns[i].required&&_4f[_51].$trim()==""){
  460. alert(_4e.lang["require"].replace("%s",_4e.columns[i].title));
  461. return null;
  462. }
  463. }
  464. }
  465. }
  466. return _4f;
  467. };
  468. maxTable.data.applyRowDataMove=function(_53){
  469. var _54=_53.data[_53.inEditDataIndex];
  470. var _55=_53.data[_53.inEditDataIndex+_53.moveOffset];
  471. if(_53.moveOffset<0){
  472. _53.data.splice(_53.inEditDataIndex,1);
  473. _53.data.splice(_53.inEditDataIndex+_53.moveOffset,1,_54,_55);
  474. }else{
  475. _53.data.splice(_53.inEditDataIndex+_53.moveOffset,1,_55,_54);
  476. _53.data.splice(_53.inEditDataIndex,1);
  477. }
  478. _53.inEditDataIndex+=_53.moveOffset;
  479. _53.moveOffset=0;
  480. };
  481. maxTable.action={};
  482. maxTable.action.addRow=function(_56,_57){
  483. if(_56.inAction=="edit"||_56.inAction=="add"){
  484. if(maxTable.action.saveEdit(_56)){
  485. maxTable.action.addRow(_56,_57);
  486. }
  487. return;
  488. }
  489. if(_56.inAction!=""){
  490. return;
  491. }
  492. _56.inAction="pre_add";
  493. var _58=maxTable.ui.addRow(_56,_57);
  494. maxTable.action.editRow(_56,_58);
  495. };
  496. maxTable.action.addRowEventHelper=function(_59,_5a,i){
  497. if(_59.columns[i].type=="radio"){
  498. _5a.onclick=function(){
  499. return maxTable.action.radioClick(_59,_5a,i);
  500. };
  501. }
  502. if(_59.columns[i].type=="checkbox"){
  503. _5a.onclick=function(){
  504. return maxTable.action.checkBoxClick(_59,_5a,i);
  505. };
  506. }
  507. };
  508. maxTable.action.editRow=function(_5c,_5d){
  509. if(!_5c.allowEdit){
  510. return;
  511. }
  512. if(typeof (_5d)=="number"){
  513. _5d=$id(_5c.id).rows(_5d+1);
  514. }
  515. if(_5c.inEditRow==_5d){
  516. return;
  517. }
  518. if(_5c.inEditRow!=_5d&&(_5c.inAction=="add"||_5c.inAction=="edit")){
  519. if(_5c.inAction=="add"){
  520. maxTable.action.cancelEdit(_5c);
  521. maxTable.action.editRow(_5c,_5d);
  522. }else{
  523. if(maxTable.action.saveEdit(_5c)){
  524. maxTable.action.editRow(_5c,_5d);
  525. }
  526. }
  527. return;
  528. }
  529. if(!_5c.event.beforeEdit(_5d.rowIndex-1)){
  530. _5c.inEditRow=null;
  531. _5c.inEditDataIndex=-1;
  532. return;
  533. }
  534. maxTable.ui.editRow(_5c,_5d.rowIndex-1);
  535. _5c.event.afterEdit();
  536. };
  537. maxTable.action.moveRow=function(_5e,_5f){
  538. var _60=$id(_5e.id);
  539. var _61=_5e.inEditRow.rowIndex;
  540. if(_5f==-1){
  541. if(_61==1&&_5f==-1){
  542. return;
  543. }
  544. _60.moveRow(_61,_61-1);
  545. if(_5e.showEditControl){
  546. _60.moveRow(_61+1,_61);
  547. }
  548. }else{
  549. if(_61==(_60.rows.length-(_5e.showEditControl?3:2))&&_5f==1){
  550. return;
  551. }
  552. if(_5e.showEditControl){
  553. _60.moveRow(_61+1,_61+2);
  554. }
  555. _60.moveRow(_61,_61+1);
  556. }
  557. _5e.moveOffset+=_5f;
  558. };
  559. maxTable.action.saveEdit=function(_62){
  560. if(_62.inAction!="add"&&_62.inAction!="edit"){
  561. return false;
  562. }
  563. _62.inEditResultData=maxTable.data.getEditResult(_62);
  564. if(!_62.inEditResultData){
  565. return false;
  566. }
  567. if(_62.inAction=="add"){
  568. if(!_62.event.beforeAdd()){
  569. return false;
  570. }
  571. }else{
  572. if(!_62.event.beforeUpdate()){
  573. return false;
  574. }
  575. }
  576. if(_62.moveOffset!=0){
  577. maxTable.data.applyRowDataMove(_62);
  578. }
  579. _62.data[_62.inEditDataIndex]=$clone(_62.inEditResultData);
  580. if(_62.inAction=="add"){
  581. _62.event.afterAdd();
  582. }else{
  583. _62.event.afterUpdate();
  584. }
  585. _62.inEditResultData=null;
  586. _62.inAction="save";
  587. maxTable.action.cancelEdit(_62);
  588. return true;
  589. };
  590. maxTable.action.deleteEdit=function(_63){
  591. if(_63.inAction!="edit"){
  592. return;
  593. }
  594. if(!_63.event.beforeDelete(_63.data[_63.inEditDataIndex])){
  595. return;
  596. }
  597. if(!confirm(_63.lang["delete_confirm"])){
  598. return;
  599. }
  600. var _64=maxTable.ui.deleteRow(_63,_63.inEditDataIndex);
  601. _63.event.afterDelete(_64);
  602. _63.inAction="";
  603. _63.inEditRow=null;
  604. _63.inEditDataIndex=-1;
  605. };
  606. maxTable.action.cancelEdit=function(_65){
  607. if(_65.inAction==""){
  608. return;
  609. }
  610. if(!_65.event.beforeCancel()){
  611. return;
  612. }
  613. maxTable.ui.cancelEditRow(_65);
  614. _65.event.afterCancel();
  615. };
  616. maxTable.action.radioClick=function(_66,_67,_68){
  617. if(_66.inAction!=""){
  618. maxTable.action.saveEdit(_66);
  619. }
  620. _66.inAction="radioclick";
  621. while(_67.tagName!="TR"){
  622. _67=_67.parentNode;
  623. }
  624. var _69=_67.rowIndex-1;
  625. if(!_66.event.beforeRadioClick(_69,_68)){
  626. return;
  627. }
  628. var _6a=-1;
  629. var col=_68;
  630. if(_66.dataType=="object"){
  631. col=_66.columns[_68].name;
  632. }
  633. for(var i=0;i<_66.data.length;i++){
  634. if(typeof (_66.data[i])=="object"){
  635. if(_66.data[i][col]==true){
  636. _66.data[i][col]=false;
  637. _6a=i;
  638. }
  639. }
  640. }
  641. _66.data[_69][col]=true;
  642. maxTable.ui.updateRow(_66,_6a);
  643. maxTable.ui.updateRow(_66,_69);
  644. _66.event.afterRadioClick(_6a,_69,_68);
  645. if(window.event){
  646. window.event.cancelBubble=true;
  647. }
  648. _66.inAction="";
  649. };
  650. maxTable.action.checkBoxClick=function(_6d,_6e,_6f){
  651. if(_6d.inAction!=""){
  652. maxTable.action.saveEdit(_6d);
  653. }
  654. _6d.inAction="checkclick";
  655. if(window.event){
  656. window.event.cancelBubble=true;
  657. }
  658. while(_6e.tagName!="TR"){
  659. _6e=_6e.parentNode;
  660. }
  661. var _70=_6e.rowIndex-1;
  662. if(!_6d.event.beforeCheckboxClick(_70,_6f)){
  663. return;
  664. }
  665. maxTable.ui.doCheckbox(_6d,_70,_6f);
  666. _6d.event.afterCheckboxClick(_70,_6f);
  667. _6d.inAction="";
  668. };
  669.  
  670.